<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('审核信息')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: summernote-css" />
    <style>
        body{
            width: 100%;
            height: 100%;
            background-position: center;
        }
        .input{
            width: 40px;
            border: none;
            outline: none;
        }
        .input:focus{
            outline: none;
        }
        .inputP{
            width: 40px;
            border: none;
            outline: none;
        }
        .inputP:focus{
            outline: none;
        }
        .inputN{
            width: 40px;
            border: none;
            outline: none;
        }
        .inputN:focus{
            outline: none;
        }
    </style>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-apply-edit" th:object="${wstApply}">
        <h4 class="form-header h4">审批信息</h4>
        <input name="applyId" th:field="*{applyId}" type="hidden">
        <div class="form-group" hidden>
            <label class="col-sm-3 control-label">岗位ID：</label>
            <div class="col-sm-8">
                <input name="postId" th:field="*{postId}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group" hidden>
            <label class="col-sm-3 control-label">学生ID：</label>
            <div class="col-sm-8">
                <input name="studentId" th:field="*{studentId}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">时间：</label>
            <div class="col-sm-8">
                <table border=6 bordercolor="#000000" frame=void align=center width=900px height=100px cellspacing=0px cellpadding=10px>
                    <tr height=40px align=center>
                        <th width=100px bgcolor="orchid">星期</th>
                        <th bgcolor="blanchedalmond" align=center>
                            <font>星期一</font>
                        </th>
                        <th bgcolor="mediumaquamarine">
                            <font>星期二</font>
                        </th>
                        <th bgcolor="mediumslateblue">
                            <font>星期三</font>
                        </th>
                        <th bgcolor="chocolate">
                            <font>星期四</font>
                        </th>
                        <th bgcolor="aqua">
                            <font>星期五</font>
                        </th>
                        <th bgcolor="aqua">
                            <font>星期六</font>
                        </th>
                        <th bgcolor="aqua">
                            <font>星期日</font>
                        </th>
                    </tr>
                    <tr height=40px align=center id="AM">
                        <td bgcolor="skyblue">
                            <font><b>上午</b></font>
                        </td>
                        <!--                        <td><input name="times[0].monday" id="am1" class="input" th:value="无"/></td>-->
                        <!--                        <td><input name="times[0].tuesday" id="am2" class="input" th:value="无"/></td>-->
                        <!--                        <td><input name="times[0].wednesday" id="am3" class="input" th:value="无"/></td>-->
                        <!--                        <td><input name="times[0].thursday" id="am4" class="input" th:value="无"/></td>-->
                        <!--                        <td><input name="times[0].friday" id="am5" class="input" th:value="无"/></td>-->
                        <!--                        <td><input name="times[0].saturday" id="am6" class="input" th:value="无"/></td>-->
                        <!--                        <td><input name="times[0].sunday" id="am7" class="input" th:value="无"/></td>-->
                    </tr>
                    <tr height=40px align=center id="PM">
                        <td bgcolor="skyblue">
                            <font><b>下午</b></font>
                        </td>
                        <!--                        <input type="text" name="times[1].time" th:value="2" hidden/>-->
                        <!--                        <td><input name="times[1].monday" id="pm1" class="inputP" th:value="无"/></td>-->
                        <!--                        <td><input name="times[1].tuesday" id="pm2" class="inputP" th:value="无"/></td>-->
                        <!--                        <td><input name="times[1].wednesday" id="pm3" class="inputP" th:value="无"/></td>-->
                        <!--                        <td><input name="times[1].thursday" id="pm4" class="inputP" th:value="无"/></td>-->
                        <!--                        <td><input name="times[1].friday" id="pm5" class="inputP" th:value="无"/></td>-->
                        <!--                        <td><input name="times[1].saturday" id="pm6" class="inputP" th:value="无"/></td>-->
                        <!--                        <td><input name="times[1].sunday" id="pm7" class="inputP" th:value="无"/></td>-->
                    </tr>
                    <tr height=40px align=center id="Night">
                        <td bgcolor="skyblue">
                            <font><b>晚上</b></font>
                        </td>
                        <!--                        <input type="text" name="times[2].time" th:value="3" hidden/>-->
                        <!--                        <td><input name="times[2].monday" id="night1" class="inputN" th:value="无"/></td>-->
                        <!--                        <td><input name="times[2].tuesday" id="night2" class="inputP" th:value="无"/></td>-->
                        <!--                        <td><input name="times[2].wednesday" id="night3" class="inputN" th:value="无"/></td>-->
                        <!--                        <td><input name="times[2].thursday" id="night4" class="inputN" th:value="无"/></td>-->
                        <!--                        <td><input name="times[2].friday" id="night5" class="inputN" th:value="无"/></td>-->
                        <!--                        <td><input name="times[2].saturday" id="night6" class="inputN" th:value="无"/></td>-->
                        <!--                        <td><input name="times[2].sunday" id="night7" class="inputN" th:value="无"/></td>-->
                    </tr>
                </table>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">技能、特长：</label>
            <div class="col-sm-8">
                <div class="ibox float-e-margins">
                    <div class="ibox-content" id="experience">
                        <div class="click2edit wrapper">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">勤工助学经历：</label>
            <div class="col-sm-8">
                <div class="ibox float-e-margins">
                    <div class="ibox-content" id="evaluate">
                        <div class="click2edit wrapper">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input name="remark" th:field="*{remark}" class="form-control" type="text">
            </div>
        </div>
        <h4 class="form-header h4">审批意见</h4>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">意见：</label>
            <div class="col-sm-8">
                <input name="content" class="form-control" type="text" placeholder="请填写审批意见" required>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>同 意</button>&nbsp;
                <button type="button" class="btn btn-sm btn-info" onclick="submitHandlerDisagree()"><i class="fa fa-remove"></i>拒 绝</button>&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭</button>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: summernote-js" />
<script th:inline="javascript">
    var prefix = ctx + "wstudy/process";
    $("#form-apply-edit").validate({
        focusCleanup: true
    });

    $("#evaluate").append([[${wstApply.evaluate}]])
    $("#experience").append([[${wstApply.experience}]])

    function submitHandler() {
        let params2 = {
            "receiveUserId":[[${wstApply.studentId}]],
            "status":"no",
            "content":"消息内容：同意申请此岗位！",
            "type":"审批提醒"
        }
        if ($.validate.form()) {
            $.operate.save(prefix + "/examineApply", $('#form-apply-edit').serialize()+"&status=AGREE&params[applyId]="+[[${wstApply.applyId}]],function () {
                $.operate.post( "/wstudy/message/send",params2)
            });
        }
    }
    function submitHandlerDisagree(){
        let params2 = {
            "receiveUserId":[[${wstApply.studentId}]],
            "status":"no",
            "content":"消息内容：您的条件不符合该岗位！",
            "type":"审批提醒"
        }
        if ($.validate.form()) {
            $.operate.save(prefix + "/examineApply", $('#form-apply-edit').serialize()+"&status=DISAGREE&params[applyId]="+[[${wstApply.applyId}]],function () {
                $.operate.post( "/wstudy/message/send",params2)
            });
        }
    }

    $("input[name='freeTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $(function() {
        $('.summernote').each(function(i) {
            $('#' + this.id).summernote({
                lang: 'zh-CN',
                callbacks: {
                    onChange: function(contents, $edittable) {
                        $("input[name='" + this.id + "']").val(contents);
                    },
                    onImageUpload: function(files) {
                        var obj = this;
                        var data = new FormData();
                        data.append("file", files[0]);
                        $.ajax({
                            type: "post",
                            url: ctx + "common/upload",
                            data: data,
                            cache: false,
                            contentType: false,
                            processData: false,
                            dataType: 'json',
                            success: function(result) {
                                if (result.code == web_status.SUCCESS) {
                                    $('#' + obj.id).summernote('insertImage', result.url);
                                } else {
                                    $.modal.alertError(result.msg);
                                }
                            },
                            error: function(error) {
                                $.modal.alertWarning("图片上传失败。");
                            }
                        });
                    }
                }
            });
            var content = $("input[name='" + this.id + "']").val();
            $('#' + this.id).summernote('code', content);
        })
    });
    setTimesData()
    function setTimesData() {
        let params = {
            "postId":[[${wstApply.postId}]],
            "userId":[[${wstApply.studentId}]]
        }
        $.ajax({
            url: "/wstudy/time/listTimes",
            type: 'post',
            cache: false,
            data: params,
            dataType: "json",
            success: function (result) {

                $.each(result.data,function (index,item) {
                    if (item.time=="1"){
                        let actions = []
                        actions.push('<td><input class="input" value='+item.monday+'></td>')
                        actions.push('<td><input class="input" value='+item.tuesday+'></td>')
                        actions.push('<td><input class="input" value='+item.wednesday+'></td>')
                        actions.push('<td><input class="input" value='+item.thursday+'></td>')
                        actions.push('<td><input class="input" value='+item.friday+'></td>')
                        actions.push('<td><input class="input" value='+item.saturday+'></td>')
                        actions.push('<td><input class="input" value='+item.sunday+'></td>')
                        $("#AM").append(actions)
                    }else if(item.time=="2"){
                        let actions = []
                        actions.push('<td><input class="input" value='+item.monday+'></td>')
                        actions.push('<td><input class="input" value='+item.tuesday+'></td>')
                        actions.push('<td><input class="input" value='+item.wednesday+'></td>')
                        actions.push('<td><input class="input" value='+item.thursday+'></td>')
                        actions.push('<td><input class="input" value='+item.friday+'></td>')
                        actions.push('<td><input class="input" value='+item.saturday+'></td>')
                        actions.push('<td><input class="input" value='+item.sunday+'></td>')
                        $("#PM").append(actions)
                    }else if(item.time=="3"){
                        let actions = []
                        actions.push('<td><input class="input" value='+item.monday+'></td>')
                        actions.push('<td><input class="input" value='+item.tuesday+'></td>')
                        actions.push('<td><input class="input" value='+item.wednesday+'></td>')
                        actions.push('<td><input class="input" value='+item.thursday+'></td>')
                        actions.push('<td><input class="input" value='+item.friday+'></td>')
                        actions.push('<td><input class="input" value='+item.saturday+'></td>')
                        actions.push('<td><input class="input" value='+item.sunday+'></td>')
                        $("#Night").append(actions)
                    }
                })
            }
        });

    }
</script>
</body>
</html>